//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Controls;
using System.Windows;

namespace OpenLS.Spreadsheet.UI
{
    class PopupPanel: Panel
    {
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (Children.Count == 0)
                return finalSize;
            bool first = true;
            foreach (UIElement child in Children)
            {
                if (first)
                {
                    first = false;
                    child.Arrange(new Rect(new Point(), finalSize));
                }
                else
                {
                    child.Arrange(new Rect(new Point(0, finalSize.Height), child.DesiredSize));
                }
            }
            return finalSize;
        }
        protected override Size MeasureOverride(Size availableSize)
        {
            foreach (UIElement child in Children)
            {
                child.Measure(availableSize);
            }
            if (Children.Count == 0)
                return new Size(0, 0);
            return Children[0].DesiredSize;
        }
    }
}
